<template>
    <!--
        PDF阅读器
        body-class="modalStyle" 表示样式
        size="lg" 表示模态窗口大小 xl,lg,sm,full
        hide-footer 表示隐藏底部按钮
        hide-header 表示隐藏头部内容
        no-close-on-backdrop 表示鼠标点击背景不可关闭
        hide-header-close 表示隐藏头部关闭按钮
        centered 居中
        ok-title=“确定” 
        cancel-title=取消
        @ok="handleOk" 
        @cancel="handleCancel"
        scrollable 滚动条
        hide-backdrop 隐藏背景
        wrapClassName="ant-modal-cust-warp" 
        style="top:5%;height: 85%;overflow-y: hidden" 样式
    -->
    <b-modal ref="my-modal" title="图片阅读器" size="lg" scrollable hide-footer no-close-on-backdrop>
        <div class="d-block text-center">
            <div :style="{height: winHeight}" >
                <img :src = "url" 
                :imageWidth="imageWidth" 
                :imageHeight="imageHeight" >
            </div>
        </div>
        <template slot="modal-footer">
            <!--自定义按钮-->
            <!-- <button type="button" class="btn btn-light-danger font-weight-bold mr-2" block @click="hideModal">
                <i class="icon-xl fa fa-times"></i>取消
            </button> 
            <button type="button" class="btn btn-light-success font-weight-bold mr-2" @click="doSelect">
                <i class="icon-xl fas fa-save"></i> 确定
            </button> -->
        </template>
    </b-modal>
</template>
<script>
import apiUtil from "@/core/util/apiUtil.js";
export default {
    data() {
        return {           
            url: "",
            imageWidth: "",
            imageHeight: "",
            winHeight: (window.innerHeight - 170)+"px",
        }
    },
    mounted() {
        this.$nextTick(() => {
            this.winHeight = (window.innerHeight - 170)+"px"
            // 监听窗口大小变化
            window.onresize = () => {
                this.winHeight = (window.innerHeight - 170)+"px"
            }
        })
    },
    methods: {
        showModal(imageAttribute) {           
            if(imageAttribute){
                this.url = imageAttribute.url;
                this.imageWidth = imageAttribute.w;
                this.imageHeight = imageAttribute.h;
                this.$refs['my-modal'].show();
            }
        },
        hideModal() {
            this.$refs['my-modal'].hide()
        },
        toggleModal() {
            this.$refs['my-modal'].toggle('#toggle-btn')
        },
    }
}
</script>